package draw_0728_all;

import javax.swing.*;
import java.awt.*;

public class drawui {
    public void UI(){
        JFrame jf=new JFrame();
        jf.setTitle("画图");
        jf.setSize(900,900);
        jf.setLocationRelativeTo(null);
        jf.setDefaultCloseOperation(3);

        FlowLayout flow=new FlowLayout();
        jf.setLayout(flow);

        JButton jbu1=new JButton("直线");
        JButton jbu2=new JButton("三角形");
        JButton jbu3=new JButton("多边形");
        JButton jbu4=new JButton("矩形");
        JButton blue=new JButton("蓝色");
        JButton green=new JButton("绿色");
        jf.add(jbu1);
        jf.add(jbu2);
        jf.add(jbu3);
        jf.add(blue);
        jf.add(green);

        jf.setVisible(true);

        Graphics g=jf.getGraphics();

        drawmouse mouse=new drawmouse();
        jf.addMouseListener(mouse);
        jbu1.addActionListener(mouse);
        jbu2.addActionListener(mouse);
        jbu3.addActionListener(mouse);
        jbu4.addActionListener(mouse);
        blue.addActionListener(mouse);
        green.addActionListener(mouse);

        mouse.gr=g;

    }

    public static void main(String[] args) {
        drawui a=new drawui();
        a.UI();
    }
}
